import requests

# 1.图片的网络地址
url = 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600060365380&di=9bf26e8cd4ad567a250cbbff4135276c&imgtype=0&src=http%3A%2F%2Fa3.att.hudong.com%2F64%2F52%2F01300000407527124482522224765.jpg'


# 2.发送请求获取响应
response = requests.get(url=url)

# 3.真正要的是response里的响应体

img_data = response.content
# response.text
# response.content.decode()


# 4.写入文件
file_name = 'img1.jpg'
# wb:write byte的缩写，表示写入的是字节类型
with open(f'image/{file_name}', 'wb')  as f:
    f.write(img_data)
